﻿using Microsoft.AspNetCore.Mvc;
using Surpass.Common.CustomResult;
using Surpass.Model.Dto.ResponseDto.ResponseModel.ResultModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Surpass.Admin.Controllers
{
    /// <summary>
    /// 基控制器
    /// </summary>
    [ApiController]
    public class BaseController: Controller
    {
        /// <summary>
        /// 返回Json数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ActionResult MyJson(BaseResponseModel data)
        {
            return new CustomJsonResult
            {
                Data = data,
                DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
            };
        }

        /// <summary>
        /// 返回成功
        /// Json格式
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ActionResult Succeed<T>(T data)
        {
            return MyJson(new ResponseModel().Succeed(data));
        }

        
    }
}
